package cn.lambda.RunDemo;

import java.util.function.IntBinaryOperator;
import java.util.function.IntPredicate;

public class LambdaDemo {

    public static void main(String[] args) {

        //检测是否lambda   Alt+Enter

//        new Thread(new Runnable() {
//            public void run() {
//                System.out.println(" 新线程方法被执行了！");
//            }
//        }).start();


//        new Thread(()->{
//            System.out.println(" 新线程方法被执行了！");
//        }).start();

//        int i=calculateNum(new IntBinaryOperator() {
//            @Override
//            public int applyAsInt(int left, int right) {
//                return left+right;
//            }
//        });
//
//        int i=calculateNum((int left, int right) ->{
//                return left+right;
//        });


//        System.out.println("i = " + i);


        printNum(value -> value%2==0);
        System.out.println("======= " );
        printNum((int value)-> { return value%2==0; });
    }

    public static int calculateNum(IntBinaryOperator operator){
        int a=10;
        int b=20;
        return operator.applyAsInt(a,b);
    }




    public static void printNum(IntPredicate intPredicate){
        int[] arr={1,2,3,4,5,6,7,8,9,10};

        for (int i = 0; i < arr.length; i++) {
            if(intPredicate.test(i)){
                System.out.println("i = " + i);
            }
        }
    }

}
